<html>
<head>
<meta http-equiv="content-type" content = "text/html;charset=utf-8">
<script type = "text/javascript">
var XHR = null;

function startRequest(){
    XHR = new XMLHttpRequest();
    XHR.open("GET","poetry.txt",true);
    XHR.onreadystatechange=handleStateChange;
    XHR.send(null);
}
function handleStateChange(){
    if(XHR.readyState == 4){
        if(XHR.status == 200){
        document.getElementById("span1").innerHTML=XHR.responseText;
        }else{
        document.getElementById("span1").innerHTML="error!";
        //window.alert("");
        }
    }
}
</script>
</head>
<body>
<form id="form1">
<input id="button1" type="button" value="顯示" onclick="startRequest()">
<br><br><span id="span1"></span>
</form>
<pre>
javascript有分大小寫
document.getElementById 正確
document.getElementByid 錯誤

html標籤的屬性等號兩旁不要加空白
id="span1" 正確
id = "span1" 錯誤
</pre> 
</body>
</html>